home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 013a / formfeed.zip / FORMFEED.ASM < prev    next >
Assembly Source File  |  1992-01-11  |  6KB  |  111 lines

  1. ; =====================================================
  2. ; FORMFEED 1.0 - Copyright (C) 1992 by Michael Sigmundt
  3. ; =====================================================
  4.  
  5.            name      FORMFEED
  6.            page      63,80
  7.            title     FORMFEED.COM -- Shift-PrnScrn Sends Formfeed to Printer
  8.  
  9. lf         equ       10                     ; Linefeed Character for the screen
  10. formfeed   equ       12                     ; Formfeed Character
  11. cr         equ       13                     ; Return Character for the screen
  12. escape     equ       27                     ; Decimal ESC character
  13. reset_code equ       'E'                    ; Laser printer reset character(s)
  14. printport  equ       0                      ; Printer Port 0 = LPT1, 1 = LPT2
  15.  
  16. _CODE      segment   word public 'CODE'
  17.            org       100h                   ; All .COM files start at 100h
  18.            assume    cs:_CODE,ds:_CODE      ; Assume that CS = DS
  19.  
  20. start:     jmp       init                   ; Jump to Setup Routine
  21.  
  22.            int_old   label word             ; Memory Variable to store
  23.            int_addr  dd    0                ;  old Prn Scrn interrupt address
  24.  
  25. prog       proc      near                   ; Interrupt Routine
  26.            push      ax                     ; Save all Registers
  27.            push      bx
  28.            push      cx                     ; Flags do not need to be
  29.            push      dx                     ;  pushed since they are
  30.            push      di                     ;  automatically pushed
  31.            push      si                     ;  when an interrupt is
  32.            push      ds                     ;  first called.
  33.            push      es
  34.            mov       ax,cs
  35.            mov       ds,ax                  ; Set data segment = code segment
  36.  
  37.            mov       dx,printport           ; Printer Port
  38.            mov       ah,02h                 ; Function 02
  39.            int       17h                    ; Check Printer Port Status
  40.            and       ah,10010000b           ; Bits 4 & 7 must both be 1 to print
  41.            cmp       ah,10010000b           ; AND & CMP, Can't TEST for 2 bits
  42.            je        prn_ok                 ; If equal, go ahead and print
  43.            mov       ax,0e07h               ; Put 0e in AH, and Bell Char. in AL
  44.            mov       bx,0h                  ; Text Page 0 and Colour 0
  45.            int       10h                    ; Write Bell Character to Console
  46.            jmp       exit_prog              ; Jump to end of program
  47.  
  48. prn_ok:    mov       ah,02h                 ; Function 02h
  49.            int       16h                    ; Get Keyboard Flags
  50.            test      al,00000001b           ; Test bit 0 for Right-Shift key
  51.            jnz       do_form                ; If pressed, do a formfeed,
  52.            test      al,00000010b           ; Test bit 1 for Left-Shift key
  53.            jnz       do_reset               ; If pressed, reset printer
  54.                                             ;  otherwise do original Print Scrn
  55.            pushf                            ; Push Flags before calling original
  56.            call      int_addr               ;  interrupt since it will pop flags
  57.            jmp       exit_prog              ; Jump to the end of the program
  58.  
  59. do_form:   mov       dx,printport           ; Printer Port Number
  60.            mov       ah,0h                  ; Function number 00h
  61.            mov       al,formfeed            ; Formfeed Character
  62.            int       17h                    ; Write character to printer
  63.            jmp       exit_prog
  64.  
  65. do_reset:  mov       dx,printport           ; Printer Port Number
  66.            mov       ah,0h                  ; Function number 00h
  67.            mov       al,escape              ; Escape Character
  68.            int       17h                    ; Write Escape Character
  69.            mov       ah,0h                  ; Function number 00h
  70.            mov       al,reset_code          ; Reset Character to follow Escape
  71.            int       17h                    ; Write Reset Character
  72.  
  73. exit_prog: pop       es                     ; Restore all Registers
  74.            pop       ds
  75.            pop       si
  76.            pop       di
  77.            pop       dx
  78.            pop       cx
  79.            pop       bx
  80.            pop       ax
  81.            iret                             ; Interrupt Return
  82. prog       endp
  83.  
  84. init       proc      near                   ; Setup routine
  85.            mov       ah,09h                 ; Funtion 09 displays a string
  86.            mov       dx,offset message      ; Point DX to start of string
  87.            int       21h                    ; Display string
  88.            mov       ah,35h                 ; Function 35 gets interrupt vector
  89.            mov       al,05h                 ; Prn Scrn Interrupt number
  90.            int       21h                    ; Get Interrupt Vector
  91.            mov       int_old,bx             ; Store Old Offset
  92.            mov       int_old[2],es          ; Store Old Segment
  93.            mov       ah,25h                 ; Function 25 sets interrupt vector
  94.            lea       dx,prog                ; Put Offset of prog into DX
  95.            int       21h                    ; Set Interrupt Vector to prog
  96.            mov       dx,offset init         ; Last address to keep in memory
  97.            int       27h                    ; Terminate and stay resident
  98. init       endp
  99.  
  100. message    db        cr,lf
  101.            db        'FORMFEED 1.0 - Copyright (C) 1992 by Michael Sigmundt',cr,lf
  102.            db        '=====================================================',cr,lf,lf
  103.            db        'Press [Right Shift] + [Print Scrn] to send a FormFeed to LPT1',cr,lf
  104.            db        'Press  [Left Shift] + [Print Scrn] to send a ESC + E  to LPT1 (LaserJet Reset)',cr,lf,lf
  105.            db        'A Beep indicates that the printer in not accepting data...',cr,lf
  106.            db        '$'
  107.  
  108. _CODE      ends
  109.  
  110.            end       start                  ; Start is where to begin execution
  111.